package com.zhuhanpeng.cloud.fileB.controller;

import com.obs.services.ObsClient;
import com.zhuhanpeng.cloud.fileB.entity.FileSynchEntity;
import com.zhuhanpeng.cloud.fileB.service.fileService;
import com.zhuhanpeng.cloud.spring.control.BaseController;
import com.zhuhanpeng.cloud.spring.util.OBSUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author bjc:
 * @create 2023-02-23 下午 11:22
 */
@Controller
@RequestMapping("/fileB")
public class FileController01 extends BaseController {
private static final String endPoint = "obs.cn-east-3.myhuaweicloud.com";
private static final String ak = "NBRNPUBOGEDBCP2QFXF4";
private static final String sk = "9Hf39N5LbMWXPVbY1IVH3XHEpysob1hVaTLll6SP";
public static String BUCKET_NAME = "ntlg-obs";

    private Logger logger = LogManager.getLogger(this.getClass());

    @Resource
    private fileService fileService;

    @RequestMapping("queryAllFileInfoList")
    @ResponseBody
    public String queryAllFileInfoList() {
        ObsClient obsClient = new ObsClient(ak,sk,endPoint);
//        obsClient.listObjects();

        FileSynchEntity fileSynchEntity = new FileSynchEntity();
        fileSynchEntity = fileService.queryAllFileInfoList();
        return successObjJson("file.synch.success",fileSynchEntity);
    }
}
